﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace WoChu.CF.BaseFrame.Util
{
    public class MessageBoxEx
    {
        /// <summary>
        /// 显示提示消息
        /// </summary>
        /// <param name="msg"></param>
        public static void Show(string msg)
        {
            System.Windows.Forms.MessageBox.Show(msg);
        }

        /// <summary>
        ///显示提示消息
        /// </summary>
        /// <param name="e"></param>
        public static void Show(Exception e)
        {
            RfAppException aEx = e as RfAppException;
            if (aEx == null)
            {
                System.Windows.Forms.MessageBox.Show(e.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                return;
            }
            if (aEx.MsgLever == SysMessageLevel.DisplayToUser)
            {
                System.Windows.Forms.MessageBox.Show(aEx.Message, "操作提示");
            }
            else if (aEx.MsgLever == SysMessageLevel.SysDatabaseInfo)
            {
                System.Windows.Forms.MessageBox.Show(aEx.Message, "数据库操作异常");
            }
            else if (aEx.MsgLever == SysMessageLevel.SysErrInfo)
            {
                System.Windows.Forms.MessageBox.Show(aEx.Message, "系统异常");

            }
            else if (aEx.MsgLever == SysMessageLevel.SysFileInfo)
            {
                System.Windows.Forms.MessageBox.Show(aEx.Message, "文件操作异常");

            }
            else if (aEx.MsgLever == SysMessageLevel.SysWarning)
            {
                System.Windows.Forms.MessageBox.Show(aEx.Message, "操作警告");
            }
            else if (aEx.MsgLever == SysMessageLevel.CodeRunInfo)
            {
                System.Windows.Forms.MessageBox.Show(aEx.Message, "代码编辑异常");
            }
            else if (aEx.MsgLever == SysMessageLevel.WebService)
            {
                System.Windows.Forms.MessageBox.Show(aEx.Message, "WebService调用出错");
            }
            else
            {
                System.Windows.Forms.MessageBox.Show(e.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            }
        }
        /// <summary>
        /// 消息询问
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static System.Windows.Forms.DialogResult Question(string msg)
        {
            return System.Windows.Forms.MessageBox.Show(msg, "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
        }
    }
}
